package Lee_code;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class compator {
    public static void main(String[] args) {
        List<Person> people = new ArrayList<>();
        people.add(new Person("Alice", 25));
        people.add(new Person("Bob", 30));
        people.add(new Person("Charlie", 20));

        people.sort((o1, o2) -> {
            int age1 = o1.getAge();
            int age2 = o2.getAge();
            return Integer.compare(age2, age1);
        });

        for (Person person: people){
            System.out.println(person);
        }

    }
}
